/*
*
* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2011-2018 ARM or its affiliates
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "acamera_command_api.h"
//#include "acamera_firmware_api.h"
#include "acamera_firmware_settings.h"
// created from 2016-10-19T16:42:58.865Z UTClinear.json

// CALIBRATION_LIGHT_SRC
static uint16_t _calibration_light_src[][2] = {
  {288,241}};

// CALIBRATION_RG_POS
static uint16_t _calibration_rg_pos[]
 = {165,180,197,214,232,256,266,283,301,318,335,352,370,387,423};

// CALIBRATION_BG_POS
static uint16_t _calibration_bg_pos[]
 = {156,176,186,197,207,218,228,239,249,256,270,281,291,302,326};

// CALIBRATION_MESH_RGBG_WEIGHT
static uint16_t _calibration_mesh_rgbg_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 35, 89, 256, 208 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 2, 12, 52, 148, 256, 256, 4 },
  { 0, 0, 0, 0, 0, 0, 0, 3, 17, 68, 182, 256, 256, 161, 0 },
  { 0, 0, 0, 0, 0, 1, 3, 20, 77, 195, 256, 256, 163, 30, 0 },
  { 0, 0, 0, 0, 0, 11, 28, 99, 223, 256, 256, 147, 24, 1, 0 },
  { 0, 0, 0, 0, 4, 59, 118, 256, 256, 256, 141, 25, 2, 0, 0 },
  { 0, 0, 0, 1, 28, 225, 256, 256, 256, 116, 18, 1, 0, 0, 0 },
  { 0, 0, 0, 11, 123, 256, 256, 256, 103, 15, 1, 0, 0, 0, 0 },
  { 0, 0, 1, 44, 256, 256, 256, 166, 22, 2, 0, 0, 0, 0, 0 },
  { 0, 0, 31, 256, 256, 192, 75, 7, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 2, 256, 256, 256, 23, 5, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 21, 256, 256, 52, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 256, 256, 49, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 9, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};

// CALIBRATION_MESH_LS_WEIGHT
static uint16_t _calibration_mesh_ls_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 57, 198, 238, 256, 256, 256, 256, 256, 238, 198, 57, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};

// CALIBRATION_MESH_COLOR_TEMPERATURE
static uint16_t _calibration_mesh_color_temperature[][15] = {
  { 169, 183, 198, 208, 227, 257, 269, 286, 303, 320, 333, 347, 366, 381, 385 },
  { 159, 173, 188, 200, 216, 242, 256, 274, 292, 308, 325, 338, 354, 370, 385 },
  { 154, 167, 183, 198, 211, 236, 247, 269, 286, 303, 319, 334, 350, 365, 385 },
  { 154, 162, 177, 192, 205, 231, 241, 262, 280, 297, 313, 330, 345, 359, 385 },
  { 150, 156, 172, 187, 200, 225, 236, 256, 275, 291, 308, 324, 341, 356, 385 },
  { 143, 154, 166, 181, 198, 220, 230, 248, 268, 285, 302, 318, 337, 351, 385 },
  { 137, 150, 161, 176, 192, 214, 225, 243, 263, 279, 296, 313, 330, 347, 385 },
  { 133, 144, 155, 170, 187, 208, 219, 237, 256, 273, 290, 306, 324, 343, 368 },
  { 133, 137, 153, 165, 181, 203, 214, 232, 250, 268, 284, 301, 318, 338, 363 },
  { 130, 133, 148, 161, 178, 200, 210, 228, 247, 264, 280, 297, 314, 336, 359 },
  { 119, 130, 140, 154, 170, 192, 203, 221, 239, 256, 272, 289, 307, 323, 385 },
  { 111, 122, 133, 148, 165, 186, 195, 215, 234, 250, 266, 283, 300, 317, 356 },
  { 103, 115, 127, 142, 159, 181, 190, 210, 228, 246, 262, 277, 295, 311, 352 },
  { 100, 106, 119, 135, 151, 175, 184, 204, 223, 241, 255, 271, 289, 305, 348 },
  { 100, 100, 100, 114, 127, 163, 172, 187, 210, 228, 246, 259, 275, 292, 338 }};

// RG, BG, MULT. final wb gain adjuster for a sky scene. devided by CALIBRATION_WB_STRENGTH_MULT in use
static uint16_t _calibration_wb_strength[] = {1000, 1000, 1000};

// lux threshold for sky
static uint16_t _calibration_sky_lux_th[] = {10000};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_rg_pos_calc[]
 = {180,202,219,256,295,304,358,380,404};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_bg_pos_calc[]
 = {312,290,278,256,237,232,202,190,177};

// CALIBRATION_COLOR_TEMP
static uint16_t _calibration_color_temp[]
 = {100,133,154,200,250,263,333,357,385};

// CALIBRATION_CT65POS
static uint16_t _calibration_ct65pos[] = {2};

// CALIBRATION_CT40POS
static uint16_t _calibration_ct40pos[] = {8};

// CALIBRATION_CT30POS
static uint16_t _calibration_ct30pos[] = {6};

// CALIBRATION_EVTOLUX_EV_LUT
static uint32_t _calibration_evtolux_ev_lut[]
 = {101156,188068,303007,605059,944040,1216255,1296431,1473159,1820856,2067789,2319065,2994398,4858650};

// CALIBRATION_EVTOLUX_LUX_LUT
static uint32_t _calibration_evtolux_lux_lut[]
 = {18000,15000,10000,5000,2000,1000,800,500,200,100,50,10,1};

// CALIBRATION_BLACK_LEVEL_R
static uint16_t _calibration_black_level_r[][2] = {
  { 0, 273 },
  { 32, 273 },
  { 64, 273 },
  { 96, 273 }};

// CALIBRATION_BLACK_LEVEL_GR
static uint16_t _calibration_black_level_gr[][2] = {
  { 0, 273 },
  { 32, 273 },
  { 64, 273 },
  { 96, 273 }};

// CALIBRATION_BLACK_LEVEL_GB
static uint16_t _calibration_black_level_gb[][2] = {
  { 0, 273 },
  { 32, 273 },
  { 64, 273 },
  { 96, 273 }};

// CALIBRATION_BLACK_LEVEL_B
static uint16_t _calibration_black_level_b[][2] = {
  { 0, 273 },
  { 32, 273 },
  { 64, 273 },
  { 96, 273 }};

// CALIBRATION_STATIC_WB
static uint16_t _calibration_static_wb[]
 = {465,256,256,430};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_a_ccm[]
 = {401,32858,32823,32850,468,32898,32781,33022,523};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d40_ccm[]
 = {436,32911,32805,32845,481,32916,32776,33004,500};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d50_ccm[]
 = {447,32930,32797,32839,482,32923,32773,32985,478};

// CALIBRATION_SHADING_LS_A_R
static uint8_t _calibration_shading_ls_a_r[]
 = {242,218,198,181,165,153,143,136,128,122,115,110,106,103,100,100,100,101,103,106,110,116,123,130,137,144,151,162,175,192,211,231,232,209,191,174,161,148,139,131,124,117,111,105,102,98,97,96,96,97,99,102,105,111,118,124,132,139,147,157,170,186,202,223,225,202,185,169,156,145,136,127,120,112,106,101,97,94,93,92,92,93,94,98,102,107,113,120,127,135,144,152,164,180,197,219,219,197,180,165,152,141,132,123,116,108,102,97,93,91,89,88,88,89,91,93,97,103,109,116,123,131,140,149,161,175,192,213,213,192,176,160,148,138,128,119,111,104,98,93,89,87,85,85,84,85,87,90,94,99,105,112,119,127,136,145,157,170,187,208,208,186,170,156,144,134,124,115,107,100,94,90,86,83,82,81,81,82,84,87,90,95,101,108,116,124,133,142,153,165,183,204,203,183,167,152,141,131,121,112,104,97,91,87,82,81,79,78,78,79,81,84,87,92,98,105,112,121,131,139,149,162,178,199,199,179,163,149,138,128,118,109,101,94,89,84,80,78,77,76,75,76,78,81,85,89,95,101,109,118,128,137,147,160,175,195,196,175,159,146,135,124,115,106,98,92,86,82,78,76,74,73,73,74,76,79,82,87,92,99,107,116,125,134,145,156,172,191,194,173,157,144,133,123,113,104,96,90,84,80,76,74,72,71,71,72,74,76,80,84,90,96,104,113,123,132,143,153,169,189,192,171,155,142,131,121,111,102,94,88,82,78,75,72,70,69,69,70,72,75,78,83,88,94,102,111,120,130,141,152,167,186,189,169,154,141,130,120,109,100,93,86,81,76,73,71,69,68,68,68,70,73,76,81,87,93,100,109,119,128,140,150,165,183,188,169,152,140,129,118,108,99,91,85,80,75,72,69,67,66,66,67,69,72,75,80,85,92,99,107,117,127,138,149,163,181,185,167,152,140,128,116,106,98,90,84,79,74,71,68,66,65,65,66,68,71,74,79,84,90,98,106,116,126,137,148,162,180,183,165,151,138,127,116,106,97,89,83,78,73,70,67,66,65,65,65,67,70,73,78,83,90,97,106,115,125,136,147,161,179,183,165,150,138,127,116,106,97,89,83,78,73,70,67,65,64,64,65,67,69,73,78,83,89,96,105,115,125,135,146,160,178,183,165,150,138,127,115,105,96,89,83,77,73,69,67,65,64,64,65,67,69,73,77,83,89,96,105,114,124,135,146,160,177,183,164,150,138,126,116,105,97,89,83,78,73,69,67,65,64,64,65,67,69,73,77,83,89,96,104,115,124,134,146,160,177,184,165,150,139,127,116,106,97,90,83,78,74,70,67,65,65,65,65,67,70,73,78,83,90,97,105,115,125,135,146,160,177,185,166,150,139,128,117,106,98,90,84,79,74,71,67,66,65,65,66,68,71,74,79,84,90,98,106,115,125,136,147,161,179,185,166,151,140,128,118,107,99,91,85,80,75,71,69,67,66,66,67,69,72,75,80,85,92,98,107,116,127,136,148,162,180,186,167,151,139,129,119,108,100,93,86,81,76,73,70,68,67,67,68,70,73,76,81,86,93,100,108,118,128,137,149,164,183,187,168,153,140,130,120,111,102,94,88,82,78,74,72,70,69,69,70,72,75,78,82,87,94,101,110,119,129,139,150,165,185,189,169,154,142,132,122,113,104,96,90,84,80,76,73,72,71,71,72,73,76,79,83,89,96,103,111,121,130,141,153,168,187,192,173,156,143,134,124,115,106,98,92,86,82,78,76,74,73,73,74,76,78,81,85,91,98,105,114,123,133,143,155,170,191,197,176,160,146,136,126,118,109,101,94,89,84,81,78,76,75,75,76,78,80,83,88,94,100,108,117,126,135,146,158,175,195,200,179,163,149,138,129,120,112,104,97,91,87,83,80,79,78,78,78,80,83,86,91,96,103,111,120,128,138,148,161,178,199,202,182,165,152,140,132,123,115,107,100,94,90,86,83,81,80,80,81,83,85,89,93,99,106,114,123,131,141,151,165,181,202,206,185,169,156,144,134,126,118,110,103,98,93,89,87,85,84,83,84,86,89,92,97,102,109,117,126,134,143,155,169,185,204,211,189,173,159,147,137,129,121,114,107,101,96,93,90,88,87,87,88,89,92,96,101,106,113,121,129,137,147,159,172,189,210,215,194,177,162,150,140,132,124,117,111,105,100,96,94,92,91,91,91,93,96,99,105,110,117,124,132,141,151,163,177,191,210,221,199,182,166,153,143,136,128,121,114,109,104,100,97,95,94,94,95,97,99,104,108,114,121,129,136,145,156,168,183,197,213};

// CALIBRATION_SHADING_LS_A_G
static uint8_t _calibration_shading_ls_a_g[]
 = {207,186,169,154,141,131,124,117,112,106,102,98,95,93,91,90,90,91,92,95,98,102,106,111,117,123,129,138,150,164,179,195,200,179,163,150,137,128,120,114,108,103,98,95,92,90,88,87,87,88,89,91,94,98,103,107,113,119,126,134,145,159,172,190,194,174,158,145,134,125,117,111,105,100,95,91,88,86,85,84,84,85,86,88,91,95,99,104,110,116,122,130,141,154,168,187,188,169,154,141,130,122,115,108,102,96,92,88,85,83,82,82,82,82,83,86,88,92,96,101,107,113,119,127,136,150,164,181,184,165,150,137,127,119,112,105,99,93,89,86,83,81,80,79,79,80,81,83,86,89,93,98,104,110,117,124,133,145,160,178,180,161,146,134,124,116,109,102,96,91,87,83,80,79,77,77,77,77,79,81,83,87,91,96,101,108,114,121,130,142,156,174,177,158,143,131,122,114,107,100,94,88,84,81,78,77,75,75,75,75,77,79,81,85,89,93,99,105,112,119,128,139,153,171,173,154,140,128,119,112,104,97,91,86,82,79,76,75,73,73,73,73,75,77,79,83,86,91,97,103,110,117,126,136,150,167,170,151,137,126,118,110,102,95,89,85,80,77,75,73,72,71,71,72,73,75,77,81,85,89,95,101,108,116,124,134,147,164,168,150,135,125,116,108,101,94,88,83,79,76,73,71,70,69,69,70,71,73,76,79,83,88,93,99,107,114,122,132,145,162,165,148,134,123,115,106,99,92,87,82,78,75,72,70,69,68,68,69,70,72,74,78,82,86,92,98,105,113,121,130,143,159,163,146,132,122,114,105,98,91,85,81,77,74,71,69,68,67,67,67,69,71,73,77,81,85,90,97,104,112,119,129,141,157,161,144,132,121,113,104,97,90,85,80,76,73,70,68,66,66,66,66,68,70,72,76,80,84,89,96,103,110,118,128,140,155,159,143,131,121,112,104,96,90,84,79,75,72,69,67,66,65,65,66,67,69,72,75,79,83,89,95,102,110,117,127,139,154,158,143,130,120,111,103,96,89,83,79,75,71,69,67,65,64,64,65,66,69,71,75,78,83,88,94,101,109,117,126,138,153,158,142,130,120,111,103,95,89,83,79,75,71,69,66,65,64,64,65,66,68,71,74,78,83,88,94,101,109,117,126,138,152,157,142,130,120,111,103,95,89,83,79,75,71,68,66,65,64,64,65,66,68,71,74,78,82,88,94,101,109,117,125,137,152,158,142,130,120,112,103,95,89,83,79,75,71,68,66,65,64,64,65,66,68,71,74,78,83,88,94,101,109,117,126,138,152,158,142,130,121,112,103,96,89,84,79,75,72,69,67,65,65,65,65,67,69,71,75,79,83,88,94,101,109,117,126,138,153,158,143,131,121,112,104,96,90,84,80,76,72,69,67,66,65,65,66,67,69,72,75,79,84,89,95,102,109,117,127,139,154,159,144,131,121,113,105,97,90,85,80,76,73,70,68,67,66,66,67,68,70,73,76,80,84,89,96,103,110,118,127,140,155,160,144,132,122,114,106,98,92,86,81,77,74,71,69,68,67,67,68,69,71,74,77,81,85,90,97,104,111,119,129,141,157,162,146,133,123,115,107,100,93,87,82,78,75,72,70,69,68,68,69,70,72,75,78,82,86,92,98,105,113,120,130,143,159,164,148,134,124,116,108,101,94,89,84,80,76,74,72,70,70,70,70,72,74,76,79,83,88,93,99,106,114,122,132,145,162,167,150,136,126,118,110,103,96,90,86,81,78,75,73,72,71,71,72,73,75,77,80,85,89,95,101,108,115,124,135,148,165,169,152,138,128,119,112,105,98,93,87,83,80,77,75,74,73,73,74,75,77,79,82,86,91,97,103,110,117,126,137,151,168,172,155,141,130,121,114,107,101,95,90,85,82,79,77,76,75,75,76,77,79,81,84,88,93,99,105,112,120,129,140,154,172,175,158,144,132,123,116,109,103,97,92,88,84,81,79,78,77,77,78,79,81,83,86,91,96,102,108,115,122,132,143,157,174,179,161,147,135,126,118,111,105,100,95,90,87,84,82,80,79,79,80,81,83,86,89,93,98,104,110,117,125,134,147,160,177,183,165,151,138,128,121,114,108,102,97,93,89,86,84,83,82,82,83,84,86,89,92,96,101,107,113,120,128,138,151,163,181,188,169,154,142,132,123,116,111,105,100,96,92,90,87,86,85,85,86,87,89,92,95,99,105,110,116,123,131,142,155,167,184,194,175,159,146,135,126,119,114,108,103,99,95,93,90,89,88,88,88,90,92,95,98,103,108,114,120,126,135,146,160,173,188};

// CALIBRATION_SHADING_LS_A_B
static uint8_t _calibration_shading_ls_a_b[]
 = {187,168,151,138,126,117,111,105,100,96,91,88,86,84,83,83,83,83,85,87,89,92,96,101,105,111,117,126,137,150,164,180,182,162,148,134,124,115,108,102,98,93,89,86,84,82,81,81,81,81,83,85,86,90,94,98,103,108,115,122,133,146,158,175,176,158,144,131,121,112,105,100,94,90,87,84,82,80,79,79,79,80,81,82,85,88,92,96,100,105,112,119,129,142,154,170,171,153,140,127,118,110,103,97,92,88,84,81,79,78,77,77,77,78,79,80,82,85,88,93,97,103,108,116,125,137,149,166,168,150,136,125,115,107,101,95,89,85,82,79,77,76,75,75,75,76,77,78,80,83,86,91,96,101,107,113,122,133,147,162,164,147,132,121,112,104,98,92,87,83,80,77,76,74,74,73,73,74,75,76,78,81,84,88,93,98,105,111,119,130,142,159,161,143,128,118,110,102,96,90,85,81,78,76,74,73,72,72,72,72,73,75,77,79,82,86,91,96,103,109,116,127,140,156,157,140,126,116,107,100,94,88,84,80,76,74,72,71,71,70,70,71,72,73,75,77,81,84,89,95,101,107,115,125,137,153,154,137,123,113,106,99,92,87,82,78,75,73,71,70,69,69,69,70,71,72,74,76,79,83,88,93,99,106,113,122,135,151,152,135,122,112,104,97,91,85,81,77,74,72,70,69,68,68,68,68,70,71,73,75,78,82,86,91,97,105,112,121,133,148,149,133,121,111,104,96,90,84,80,76,73,71,69,68,67,67,67,68,68,70,72,74,77,81,85,90,97,103,111,119,131,146,148,132,120,110,102,95,89,84,79,76,73,70,69,67,66,66,66,67,68,69,71,74,77,80,84,90,95,102,110,118,129,144,147,131,119,109,102,95,88,83,78,75,72,70,68,67,66,65,65,66,67,69,71,73,76,79,83,89,95,101,109,116,129,143,145,130,119,109,101,94,88,82,78,74,72,69,67,66,65,65,65,65,66,68,70,73,76,79,83,88,94,100,108,116,127,141,144,129,117,108,101,93,87,82,77,74,71,69,67,66,65,64,64,65,66,68,70,72,75,78,82,87,93,100,108,115,126,140,143,129,118,108,100,93,87,82,77,74,71,69,67,65,65,64,64,65,66,67,70,72,75,78,82,87,93,100,107,115,126,140,144,129,117,108,100,93,87,82,77,74,71,69,67,65,65,64,64,65,66,67,69,72,75,78,82,87,93,100,107,115,126,140,143,129,117,108,100,93,87,82,77,74,71,69,67,65,64,64,64,65,66,67,70,72,75,78,82,87,93,99,107,115,126,140,144,129,117,109,101,94,88,82,78,74,72,69,67,66,65,64,65,65,66,68,70,72,75,78,83,87,93,100,107,115,127,142,145,130,118,109,101,95,88,83,78,75,72,69,67,66,65,65,65,66,67,68,70,72,75,79,83,88,94,100,108,117,128,142,146,131,118,110,102,95,88,83,79,75,72,70,68,67,66,65,66,66,67,69,71,73,76,79,83,88,94,101,108,117,128,143,147,131,119,110,103,96,89,84,80,76,73,71,69,67,66,66,66,67,68,69,71,73,76,80,84,89,96,102,109,118,130,145,148,133,121,111,104,97,91,85,80,77,74,71,70,68,67,67,67,68,69,70,72,74,77,81,85,90,96,103,110,120,132,148,151,134,122,112,105,98,92,86,82,78,75,72,71,69,69,68,68,69,70,71,73,75,78,82,86,91,97,104,111,122,134,150,153,137,123,113,106,99,94,88,83,79,76,74,72,70,70,69,69,70,70,72,74,76,79,83,87,93,99,105,113,123,136,153,156,139,126,115,108,101,95,90,85,81,77,75,73,71,71,70,71,71,72,73,75,77,80,84,89,95,101,107,115,126,139,155,158,142,129,118,110,103,97,92,87,83,79,77,75,73,72,72,72,72,73,75,76,79,82,86,91,97,103,109,118,129,142,158,161,145,131,120,112,105,99,94,89,85,81,78,76,75,74,73,73,74,75,77,78,81,84,88,93,99,105,112,120,132,145,161,163,147,134,123,113,107,101,96,91,87,83,80,78,77,76,75,75,76,77,78,80,83,86,90,96,101,107,114,123,135,147,163,167,150,137,126,117,109,103,98,93,89,85,82,80,79,78,77,77,78,79,80,82,85,88,93,98,103,110,117,127,138,150,167,170,153,140,129,119,111,105,99,96,91,87,85,82,81,80,79,79,80,81,82,85,87,91,95,100,106,112,119,130,141,152,168,174,157,144,131,121,112,107,101,97,93,89,86,84,82,82,81,81,82,83,84,87,89,93,97,102,108,114,122,133,146,157,170};

// CALIBRATION_SHADING_LS_TL84_R
static uint8_t _calibration_shading_ls_tl84_r[]
 = {244,216,195,178,163,151,142,134,127,120,114,109,105,101,99,99,99,100,101,105,109,114,121,127,134,142,150,162,175,192,207,228,233,208,188,172,157,146,137,129,121,115,109,104,100,97,95,94,95,95,97,100,104,109,116,122,129,136,145,156,168,184,200,222,225,201,182,166,153,142,133,124,117,110,104,99,96,93,91,90,91,91,93,96,100,105,111,117,125,132,140,150,163,177,196,220,218,195,177,161,149,139,130,120,113,106,100,95,92,90,88,87,87,88,90,93,96,101,107,113,121,129,137,147,158,173,191,212,213,191,173,158,145,135,125,116,109,102,96,92,88,86,84,84,84,85,86,89,93,98,103,110,118,126,134,143,154,168,185,207,209,185,167,153,142,131,122,113,106,99,93,88,85,83,81,81,81,82,83,86,89,94,100,106,114,122,131,140,150,164,181,202,205,182,163,149,138,129,119,110,102,96,90,86,82,80,79,78,78,79,81,83,87,91,97,103,111,119,128,137,147,161,176,197,200,178,160,146,136,125,116,107,99,93,87,83,80,77,76,75,75,76,78,81,84,88,94,100,108,116,125,135,144,157,173,193,195,173,157,144,133,123,113,104,97,90,85,81,78,75,74,73,73,74,76,78,82,86,91,97,105,113,122,132,142,154,170,188,190,170,154,141,130,120,110,102,94,88,83,79,76,73,72,71,71,72,73,76,79,84,89,95,103,111,120,130,140,151,166,184,189,168,152,139,128,118,108,100,93,86,81,77,74,72,70,69,69,70,71,74,78,82,87,93,101,109,118,128,138,150,164,181,186,167,151,138,127,117,107,98,91,85,80,76,72,70,69,67,68,68,70,73,76,81,86,92,99,107,116,127,136,148,162,180,185,165,149,137,125,115,106,97,90,84,79,75,71,69,67,66,66,67,69,72,75,79,84,90,97,106,115,125,135,146,161,179,183,164,148,136,125,114,105,96,89,83,78,74,70,68,66,65,65,66,68,70,74,78,83,89,97,105,114,123,133,144,160,178,181,162,148,135,124,113,104,95,88,82,77,73,70,67,65,65,64,65,67,70,73,78,83,89,95,104,113,123,133,144,158,175,180,161,147,135,124,113,104,95,88,82,77,73,69,67,65,64,64,65,67,69,73,77,82,88,95,103,112,122,132,143,157,174,180,162,147,135,124,113,103,95,88,82,77,73,69,66,65,64,64,65,67,69,73,77,82,88,95,103,112,122,132,143,157,173,180,161,147,134,124,113,103,95,88,82,77,73,69,67,65,64,64,65,67,69,73,77,82,88,95,103,112,123,132,143,156,173,180,161,147,136,125,114,104,95,88,82,78,73,70,67,65,65,65,65,67,70,73,77,83,88,96,103,113,123,132,143,157,174,181,162,147,135,125,114,105,96,89,83,78,74,70,67,66,65,65,66,68,70,74,78,83,89,96,104,114,123,133,143,157,176,182,163,148,136,125,115,106,97,90,84,79,75,71,69,67,66,66,67,69,72,75,79,84,90,97,105,114,124,134,145,159,177,183,164,148,136,126,116,106,98,91,85,80,76,72,70,68,67,67,68,70,72,76,80,85,91,98,106,116,125,135,146,160,178,184,165,149,138,127,118,108,100,93,87,82,78,74,71,69,69,69,70,71,74,77,81,86,92,99,108,117,127,136,147,162,181,187,168,152,140,130,120,110,102,95,88,83,79,76,73,71,71,71,72,73,76,79,83,88,94,101,110,119,129,139,150,166,185,190,170,154,141,131,122,113,104,97,91,85,81,78,75,73,73,72,74,75,77,81,85,90,96,104,112,121,130,139,152,168,189,193,173,157,144,134,124,116,107,99,93,88,83,80,77,76,75,75,76,77,79,82,87,92,99,106,114,123,133,143,156,173,193,196,176,160,146,135,127,118,110,102,95,90,86,82,80,78,77,77,78,79,82,85,89,95,101,109,117,126,135,146,159,175,196,201,180,163,149,138,129,121,112,105,99,93,88,85,82,81,80,79,80,82,84,87,92,97,104,112,120,129,138,149,162,179,199,205,184,167,153,141,131,123,115,109,102,96,92,88,86,83,83,82,83,85,87,91,95,101,108,115,124,132,141,152,166,182,202,210,187,171,156,144,135,126,119,112,105,100,95,91,88,87,86,86,86,88,90,94,98,104,111,119,127,134,144,155,170,186,207,215,193,174,160,147,137,129,121,114,108,103,98,95,92,90,89,90,90,92,94,98,102,108,114,122,130,138,148,161,175,189,210,222,198,180,164,151,140,132,124,118,112,106,102,98,96,94,93,93,94,95,98,102,107,112,119,126,134,142,153,166,182,196,214};

// CALIBRATION_SHADING_LS_TL84_G
static uint8_t _calibration_shading_ls_tl84_g[]
 = {209,188,171,156,142,133,125,118,112,107,102,98,95,93,91,91,91,91,93,95,98,102,107,112,117,124,130,140,152,167,181,198,201,181,165,151,139,129,121,115,109,103,99,95,92,90,88,88,87,88,90,92,95,99,103,108,114,120,127,135,147,161,174,192,196,175,160,146,135,126,118,111,105,100,95,92,89,87,85,84,84,85,87,89,92,95,100,105,110,116,123,131,142,156,170,189,190,171,156,142,132,123,115,108,102,97,92,89,86,84,82,82,82,82,84,86,89,92,97,102,107,113,120,128,138,151,165,183,186,166,151,139,129,120,112,105,99,94,89,86,83,81,80,79,79,80,81,83,86,89,94,99,104,111,118,125,135,147,161,179,182,163,148,135,125,117,109,103,96,91,87,83,80,79,78,77,77,78,79,81,84,87,91,96,102,108,115,122,131,143,158,176,178,159,144,132,123,115,107,100,94,89,84,81,78,77,75,75,75,75,77,79,81,85,89,94,99,106,113,120,129,140,154,172,175,156,141,129,120,112,105,98,92,87,82,79,76,75,73,73,73,73,75,77,79,83,87,91,97,104,111,118,127,137,151,168,171,153,139,127,118,110,103,96,90,85,80,77,75,73,72,71,71,72,73,75,78,81,85,89,95,102,109,116,125,135,148,165,168,151,137,126,117,109,101,94,88,83,79,76,73,71,70,69,69,70,71,73,76,79,83,88,93,100,107,115,123,133,146,163,166,149,135,124,115,107,99,92,87,82,78,75,72,70,69,68,68,68,70,72,75,78,82,86,92,98,106,113,122,131,144,160,164,147,134,123,114,106,98,91,86,81,77,74,71,69,68,67,67,67,69,71,73,77,81,85,91,97,104,112,120,130,142,158,162,146,133,122,113,105,97,90,85,80,76,73,70,68,66,66,66,66,68,70,73,76,80,84,90,96,103,111,119,129,141,156,160,145,132,122,113,104,97,90,84,79,75,72,69,67,66,65,65,66,67,69,72,75,79,84,89,95,102,110,118,128,140,155,159,144,131,121,112,104,96,89,84,79,75,72,69,67,65,64,64,65,66,69,71,75,79,83,88,95,102,110,118,127,139,154,159,143,131,121,112,103,96,89,83,79,75,71,68,66,65,64,64,65,66,68,71,74,78,83,88,94,102,109,117,126,139,154,159,144,131,121,112,103,96,89,83,79,75,71,68,66,65,64,64,65,66,68,71,74,78,83,88,94,101,109,117,126,139,154,159,143,131,121,112,104,96,89,83,79,75,71,68,66,65,64,64,65,66,68,71,74,78,83,88,94,101,109,117,127,138,153,159,144,131,122,113,104,96,89,84,79,75,72,69,67,65,65,65,65,67,69,72,75,79,83,88,95,102,110,118,127,139,154,160,144,131,122,113,105,97,90,84,80,76,72,69,67,66,65,65,66,67,70,72,75,79,84,89,95,102,110,118,127,140,155,161,145,132,122,114,105,98,91,85,80,77,73,70,68,67,66,66,67,68,70,73,76,80,84,90,96,103,111,119,128,141,157,162,146,133,123,114,106,99,92,86,81,77,74,71,69,68,67,67,68,69,71,74,77,81,85,91,97,104,112,120,129,142,159,164,147,134,124,115,108,100,93,87,83,79,75,73,70,69,68,68,69,70,73,75,78,82,87,92,98,105,113,121,131,144,161,166,149,135,125,117,109,102,95,89,84,80,77,74,72,70,70,70,70,72,74,76,79,83,88,93,100,107,114,122,133,146,164,168,151,137,127,118,111,104,97,91,86,82,78,75,73,72,71,71,72,73,75,78,81,85,89,95,102,109,116,124,135,150,167,171,153,140,129,120,113,106,99,93,88,83,80,77,75,74,73,73,74,75,77,79,82,86,91,97,103,111,118,127,138,152,170,175,157,142,131,122,115,108,101,95,90,86,82,79,77,76,75,75,76,77,79,81,84,88,94,99,106,113,120,129,141,155,173,177,159,145,134,124,117,110,104,98,93,88,84,82,80,78,77,77,78,79,81,83,87,91,96,102,109,115,123,132,144,159,177,181,163,149,136,127,119,112,106,100,95,91,87,84,82,81,80,80,80,82,83,86,89,94,99,105,111,118,126,136,148,162,179,186,167,152,140,129,121,115,108,103,98,93,90,87,85,83,83,82,83,84,86,89,92,97,102,108,114,121,129,139,152,165,183,190,171,156,144,132,124,117,111,106,101,96,93,90,88,86,86,85,86,87,89,92,96,100,105,111,117,124,132,144,156,169,185,195,176,161,147,136,127,121,115,109,104,99,96,93,91,89,89,88,89,90,93,95,99,103,109,115,121,128,136,148,162,175,190};

// CALIBRATION_SHADING_LS_TL84_B
static uint8_t _calibration_shading_ls_tl84_b[]
 = {192,173,156,142,129,120,113,108,102,97,93,90,88,86,85,84,85,85,86,88,91,94,98,103,107,113,119,127,140,153,167,182,184,165,151,137,126,117,110,104,99,94,91,87,85,83,82,82,82,82,84,86,88,91,95,100,104,110,116,124,135,148,160,176,179,160,146,132,122,114,107,101,96,91,88,84,82,81,80,79,79,80,81,83,86,89,92,96,101,107,113,121,130,143,155,172,173,155,141,129,119,111,104,98,93,89,85,82,80,78,77,77,77,78,79,81,83,86,89,94,99,104,111,117,126,139,152,168,169,151,137,125,116,109,102,96,91,87,83,80,78,76,76,76,75,76,77,78,81,84,87,91,96,102,107,115,123,135,148,165,166,148,134,123,114,107,99,94,88,84,81,78,76,75,74,74,74,74,75,77,79,82,85,89,94,100,105,112,121,131,145,162,163,145,131,119,112,104,97,91,86,82,79,76,74,73,72,72,72,73,74,75,77,80,83,87,92,98,104,110,118,129,142,159,158,141,128,117,109,102,96,90,85,81,77,75,73,72,71,71,71,71,72,74,76,78,82,86,90,96,102,109,116,126,139,156,156,139,126,115,107,100,94,88,83,79,76,73,72,70,70,69,69,70,71,72,75,77,80,84,89,94,101,107,115,124,136,152,154,137,124,114,106,98,92,87,82,78,75,72,70,69,68,68,68,69,70,71,73,76,79,83,87,93,99,106,113,122,134,149,151,135,122,112,104,97,91,85,81,77,74,71,70,68,68,67,67,68,69,70,72,75,78,81,86,91,97,104,112,120,132,147,150,133,121,112,104,97,90,84,80,76,73,71,69,68,66,66,66,67,68,69,71,74,77,81,85,90,97,104,111,120,131,145,148,133,121,111,103,96,89,84,79,75,72,70,68,67,66,65,65,66,67,69,71,73,76,80,84,89,96,102,110,118,129,144,146,131,120,110,102,95,89,83,78,75,72,70,67,66,65,65,65,65,66,68,70,73,76,79,84,89,95,102,109,118,128,141,145,130,119,110,102,95,88,83,78,75,72,69,67,65,65,64,64,65,66,68,70,72,75,79,83,88,95,101,108,117,127,141,144,130,119,110,101,95,88,83,78,75,72,69,67,65,64,64,64,65,66,68,70,72,75,79,83,88,94,101,108,116,127,141,145,130,119,110,102,94,88,83,78,74,71,69,67,65,64,64,64,65,66,67,70,72,75,79,82,88,94,101,108,116,127,141,144,130,119,110,102,95,88,83,78,75,72,69,67,65,65,64,64,65,66,68,70,72,75,79,83,88,94,100,108,116,127,141,145,130,119,110,102,95,89,83,79,75,72,69,67,66,65,64,64,65,66,68,70,72,75,79,83,88,94,101,108,116,128,142,146,131,120,110,103,96,89,83,79,76,72,70,68,66,65,65,65,66,67,68,71,73,76,79,84,89,95,102,109,117,129,143,147,132,120,111,103,96,90,84,80,76,73,70,68,67,66,66,66,66,67,69,71,73,76,80,84,90,95,103,110,118,130,145,148,133,121,112,104,97,91,85,80,77,74,71,69,68,67,66,66,67,68,70,72,74,77,80,85,90,96,103,110,119,131,146,150,134,122,112,105,98,92,86,82,78,74,72,70,68,68,67,67,68,69,71,72,75,78,82,86,91,97,104,112,121,133,148,152,136,123,114,106,100,94,88,83,79,76,73,71,69,69,68,68,69,70,71,73,76,79,83,87,93,99,105,113,123,135,151,155,138,125,115,108,101,95,89,84,80,77,74,72,71,70,69,69,70,71,72,74,77,80,84,89,94,100,107,115,125,138,154,158,141,128,117,110,103,97,91,86,82,78,75,74,72,71,71,71,71,72,74,76,78,81,86,90,96,102,109,117,127,141,158,159,143,130,120,111,105,99,93,88,84,80,78,75,74,73,72,72,73,74,75,77,80,83,87,93,98,105,111,119,130,144,160,162,146,133,121,113,107,100,95,90,86,82,79,77,75,74,74,74,75,75,77,79,82,85,89,94,100,106,113,121,133,146,162,164,149,137,125,115,108,102,97,93,88,84,81,79,77,76,76,76,76,77,79,81,84,87,92,97,102,109,116,125,136,149,165,169,152,139,128,118,110,105,100,95,90,86,84,81,80,79,78,78,78,79,81,83,86,90,94,99,105,111,118,128,140,152,168,173,156,143,132,121,113,107,102,97,93,89,86,84,82,81,80,80,81,82,84,86,89,92,97,102,107,113,122,132,143,154,169,178,161,148,135,124,116,109,104,99,95,91,88,86,84,83,83,83,83,84,86,89,92,95,100,105,110,116,125,135,148,159,172};

// CALIBRATION_SHADING_LS_D65_R
static uint8_t _calibration_shading_ls_d65_r[]
 = {223,198,178,161,148,138,131,123,117,111,106,102,99,97,96,95,95,96,98,101,105,109,115,121,128,135,144,154,170,189,207,227,214,190,172,157,144,134,127,119,113,107,102,99,95,93,92,91,92,92,94,97,101,106,111,117,124,131,140,151,164,183,198,223,206,184,167,152,140,130,123,116,109,104,99,95,92,90,88,88,88,89,90,94,97,102,107,114,121,128,136,147,159,177,196,221,200,178,162,147,136,127,120,112,106,100,95,91,88,86,85,85,85,86,87,90,94,98,104,110,117,124,133,142,154,171,189,213,195,174,157,143,133,124,117,109,102,97,92,88,85,83,83,82,82,82,84,87,90,94,100,106,113,121,130,139,151,167,184,206,190,170,153,140,130,121,113,106,99,94,89,85,83,81,80,79,79,80,81,84,87,92,96,103,110,118,127,136,147,163,180,202,185,165,149,136,126,119,110,103,97,91,86,83,80,78,77,77,77,77,79,81,84,88,93,100,107,115,124,133,144,158,177,199,180,161,146,133,124,116,108,100,94,88,84,81,78,76,75,75,75,75,77,79,82,86,91,97,104,113,121,131,141,155,172,194,178,159,142,131,122,113,106,98,91,86,82,79,76,75,73,72,73,74,75,77,80,84,89,95,102,110,119,128,139,151,168,190,173,155,141,130,120,111,103,96,90,84,80,77,75,73,72,71,71,72,73,75,78,82,87,93,100,108,117,126,137,149,165,186,170,152,138,127,118,109,101,94,88,83,79,76,73,71,70,69,69,70,72,74,77,80,85,91,98,106,116,125,135,147,163,182,168,151,136,126,117,108,100,93,86,82,78,75,72,70,68,68,68,69,70,73,75,79,84,89,96,104,114,123,133,145,160,180,166,149,135,124,116,108,99,91,86,80,76,73,71,69,67,66,66,67,69,71,74,78,82,88,95,103,112,122,132,143,159,178,165,148,134,124,115,106,98,90,84,79,76,73,70,68,66,66,66,67,68,70,73,77,82,87,94,102,111,121,131,142,158,177,165,147,133,123,115,105,97,90,84,79,75,72,69,67,65,65,65,66,67,70,73,76,81,87,93,101,110,120,130,141,156,175,163,146,133,122,113,105,97,89,84,79,74,71,69,67,65,64,64,65,67,69,72,76,81,86,93,100,110,120,130,142,156,174,163,146,132,123,113,104,97,89,83,78,74,71,69,66,65,64,64,65,67,69,72,76,80,86,92,100,110,119,130,141,156,174,162,146,132,122,114,104,96,89,83,78,75,71,69,66,65,64,64,65,67,69,72,76,80,86,93,100,109,119,129,141,156,175,164,146,132,123,114,105,97,89,83,79,75,72,69,67,65,65,64,65,67,69,73,76,81,86,93,101,110,120,129,142,156,175,165,148,133,124,115,106,98,90,84,79,75,72,69,67,66,65,65,66,68,70,73,77,81,87,94,101,110,120,130,142,157,176,167,149,134,124,115,106,98,91,85,80,76,73,70,68,67,66,66,67,68,71,73,77,81,87,94,102,111,121,130,142,158,178,168,149,135,126,116,108,99,92,86,81,77,74,71,69,68,67,67,68,69,72,75,78,82,88,95,103,112,122,132,143,159,179,169,151,137,126,117,109,101,93,87,82,78,75,72,70,69,68,68,69,70,73,76,79,84,89,96,104,113,123,133,144,160,180,172,153,139,128,119,110,102,95,89,83,79,76,73,71,70,69,69,70,72,74,77,81,85,91,98,106,115,124,134,147,162,181,175,156,141,130,120,112,104,97,91,85,81,78,75,73,72,71,71,72,74,76,78,82,87,93,100,108,117,126,135,149,165,185,179,159,144,132,123,114,107,99,93,87,83,80,77,75,74,73,73,74,75,77,80,84,89,95,101,110,118,127,138,152,167,188,182,163,148,135,126,117,109,102,95,90,85,82,79,77,76,75,75,76,77,79,82,86,91,97,104,112,121,130,141,154,172,192,187,167,152,138,127,120,112,105,98,92,88,84,81,79,78,77,77,78,79,82,85,89,94,100,107,115,123,132,144,157,175,196,190,171,156,141,130,122,115,108,101,95,91,86,84,82,81,80,80,80,82,84,88,92,97,104,110,117,126,135,147,163,178,197,195,175,160,145,133,124,117,111,104,98,93,89,87,84,83,83,83,83,84,87,90,95,100,106,113,120,128,138,151,166,181,202,199,179,163,149,137,128,120,114,107,102,97,92,90,88,87,86,86,86,88,90,94,98,103,109,116,123,132,141,155,170,185,204,204,185,169,154,141,131,123,117,111,106,100,96,93,91,90,89,88,89,91,94,97,101,107,113,120,127,135,146,160,176,192,209};

// CALIBRATION_SHADING_LS_D65_G
static uint8_t _calibration_shading_ls_d65_g[]
 = {202,182,166,151,139,130,123,117,112,106,102,99,96,94,92,92,92,93,94,97,100,104,109,115,121,128,135,146,160,176,194,213,195,175,160,146,135,126,120,113,108,103,98,95,92,90,89,88,88,89,91,93,96,100,105,111,117,124,132,141,154,170,185,206,190,170,155,142,131,123,116,110,104,99,95,91,89,87,86,85,85,86,87,90,93,97,102,107,114,120,128,137,149,165,181,202,184,165,150,138,128,120,113,107,101,96,92,88,86,84,83,82,82,83,84,87,90,94,98,104,110,117,125,134,145,160,177,197,180,161,146,134,125,117,110,104,98,93,89,86,83,81,80,79,80,80,82,84,87,91,95,101,107,115,122,130,141,156,173,193,176,157,142,131,122,115,108,102,96,91,86,83,81,79,78,77,77,78,79,81,84,88,93,98,105,112,120,128,138,152,169,189,171,153,139,128,120,112,105,99,93,88,84,81,78,77,76,75,75,76,77,79,82,86,90,96,102,109,117,126,135,149,164,185,168,150,136,126,118,110,103,97,91,86,82,79,77,75,74,73,73,74,75,77,80,83,88,93,100,107,115,123,133,146,161,181,164,147,134,124,116,108,101,95,89,84,80,77,75,73,72,71,71,72,73,75,78,82,86,91,98,105,113,122,131,143,158,178,161,145,132,122,114,106,100,93,87,83,79,76,73,72,70,70,70,70,72,74,76,80,84,90,96,103,111,120,130,141,155,174,159,143,130,121,113,105,98,92,86,81,77,74,72,70,69,68,68,69,71,73,75,79,83,88,94,102,110,118,128,139,153,171,157,141,129,120,112,104,97,90,85,80,76,73,71,69,67,67,67,68,69,71,74,78,82,87,93,100,108,117,127,137,152,169,155,140,128,119,111,103,96,89,84,79,76,73,70,68,66,66,66,67,68,71,73,77,81,86,92,99,107,116,125,136,150,168,154,139,127,118,110,102,95,89,83,78,75,72,69,67,66,65,65,66,68,70,73,76,80,85,91,98,106,115,124,135,149,166,153,138,126,117,109,102,94,88,83,78,74,71,69,66,65,64,65,65,67,69,72,75,79,85,91,98,106,115,124,135,148,165,152,138,126,117,109,101,94,88,82,78,74,71,68,66,65,64,64,65,67,69,72,75,79,84,90,97,105,114,124,134,148,165,152,137,125,117,109,101,94,88,82,78,74,71,68,66,65,64,64,65,67,69,72,75,79,84,90,97,105,114,124,134,148,165,152,137,126,117,109,101,94,88,82,78,74,71,68,66,65,64,64,65,67,69,72,75,79,84,90,97,105,114,124,134,148,165,153,138,126,117,109,101,94,88,83,78,74,71,69,66,65,65,65,66,67,69,72,76,80,85,91,98,106,115,124,135,148,165,154,139,127,118,110,102,95,89,83,79,75,72,69,67,66,65,65,66,68,70,73,76,80,85,91,98,106,115,125,135,149,166,155,140,128,118,111,103,96,89,84,79,76,72,70,68,67,66,66,67,68,71,73,77,81,86,92,99,107,116,126,136,150,168,157,141,129,119,111,104,97,90,85,80,76,73,71,69,68,67,67,68,70,72,75,78,82,87,93,100,108,117,126,138,152,169,159,143,130,121,113,105,98,92,86,81,78,75,72,70,69,68,69,69,71,73,76,79,83,88,95,101,109,118,127,139,153,171,161,145,132,122,114,107,100,93,87,83,79,76,74,72,71,70,70,71,72,74,77,80,85,90,96,103,111,119,129,140,155,173,164,147,134,123,116,108,101,95,89,84,81,78,75,73,72,72,72,72,74,76,79,82,86,92,98,105,112,121,131,142,157,175,167,150,136,125,117,110,103,97,91,86,82,79,77,75,74,73,73,74,76,78,80,84,88,93,100,107,115,123,132,144,159,178,170,153,139,128,119,112,106,99,94,89,84,81,79,77,76,75,75,76,78,80,82,86,90,96,102,109,117,125,135,148,162,180,174,156,142,130,122,115,108,102,96,91,87,84,81,79,78,78,78,78,80,82,85,88,93,98,105,112,119,128,138,151,166,184,177,160,146,134,124,117,111,104,99,94,90,86,84,82,81,80,80,81,82,84,87,91,96,101,107,114,122,130,141,155,169,187,183,164,150,138,127,120,113,107,102,97,92,89,86,85,84,83,83,83,85,87,90,94,99,104,110,117,125,134,145,159,173,191,188,169,155,142,131,123,116,111,105,100,96,92,90,88,87,86,86,87,88,90,94,97,102,108,114,120,128,138,150,163,176,194,194,176,160,146,135,126,120,114,108,103,99,95,93,91,90,89,89,89,91,94,97,101,105,111,117,124,132,142,155,170,183,199};

// CALIBRATION_SHADING_LS_D65_B
static uint8_t _calibration_shading_ls_d65_b[]
 = {187,168,152,138,127,119,113,107,102,98,94,91,89,87,86,86,86,87,88,90,92,96,100,105,110,117,124,133,145,159,176,193,181,162,148,135,124,116,110,105,99,96,91,88,86,85,84,83,84,84,85,87,90,93,97,102,107,114,121,129,141,155,169,187,176,157,143,131,121,113,107,102,97,93,89,86,84,82,81,81,81,81,83,85,87,91,95,100,105,110,118,126,137,151,165,184,171,153,139,128,118,111,105,99,95,90,86,83,81,80,79,78,79,79,80,82,85,88,92,97,102,109,115,123,133,147,162,180,167,150,136,125,116,109,103,97,92,88,84,81,79,77,76,76,76,77,78,80,82,85,89,95,100,106,112,120,130,143,157,176,163,146,132,121,113,106,100,94,90,85,82,79,77,76,75,74,75,75,76,78,80,83,87,92,97,103,110,118,127,140,154,171,159,142,129,118,111,104,98,92,88,83,80,77,75,74,73,73,73,74,75,76,78,81,85,90,95,101,108,116,124,136,150,168,156,140,126,117,109,102,96,91,86,82,78,75,74,73,72,71,72,72,73,75,77,79,83,88,93,100,106,114,122,133,147,164,153,137,124,115,107,101,94,89,84,80,77,74,73,71,70,70,70,71,72,73,75,78,82,86,91,98,104,112,120,131,144,161,150,135,122,113,106,99,93,87,82,79,75,73,72,70,69,69,69,69,70,72,74,77,80,84,90,96,103,110,118,129,142,158,148,133,121,112,105,98,92,86,81,78,75,72,70,69,68,67,68,68,69,71,73,76,79,83,89,95,102,109,117,127,140,156,145,131,120,111,103,97,91,85,81,77,74,71,69,68,67,66,67,67,69,70,72,75,78,82,87,94,100,108,116,125,138,154,144,130,118,110,103,96,90,84,80,76,73,71,69,67,66,65,66,66,68,69,71,74,77,81,86,92,99,107,115,125,137,151,142,129,118,109,102,96,89,84,79,76,73,70,68,67,65,65,65,66,67,69,71,73,77,81,86,92,99,106,114,124,136,151,143,129,117,109,102,95,89,83,79,75,72,70,68,66,65,64,65,65,67,68,70,73,76,80,85,91,98,106,114,124,136,151,142,128,117,108,101,95,88,83,78,75,72,69,67,66,65,64,64,65,66,68,70,73,76,80,85,91,98,106,114,123,135,150,142,128,117,108,102,94,88,83,78,75,72,69,67,66,65,64,64,65,66,68,70,73,76,80,85,91,98,105,113,123,135,150,142,128,117,109,101,94,88,83,78,75,72,69,67,66,65,64,64,65,66,68,70,73,76,80,85,91,98,106,114,123,135,150,142,128,117,109,101,95,89,83,78,75,72,69,68,66,65,65,65,65,67,68,71,73,76,80,85,91,98,106,114,123,136,151,143,129,118,109,102,96,89,84,79,75,72,70,68,66,66,65,65,66,67,69,71,74,77,81,86,92,99,106,115,124,136,152,144,130,119,110,103,96,90,84,80,76,73,71,69,67,66,66,66,67,68,69,72,74,77,82,87,93,100,107,116,125,138,153,146,132,120,111,104,97,91,85,80,77,74,71,70,68,67,67,67,67,68,70,72,75,78,82,87,94,100,108,116,126,139,155,148,133,121,112,105,98,92,86,82,78,75,72,70,69,68,68,68,68,69,71,73,76,79,83,88,95,102,109,118,128,140,156,150,135,123,113,106,100,93,87,83,79,76,73,71,70,69,69,69,69,70,72,74,77,80,85,90,96,103,110,119,129,142,158,153,137,124,115,107,101,95,89,84,80,77,75,73,71,70,70,70,71,72,73,75,78,81,86,91,97,104,111,120,131,144,160,156,140,127,117,109,103,96,91,86,82,79,76,74,73,72,72,72,72,73,75,77,80,83,88,93,99,106,113,122,133,146,162,159,143,130,119,111,105,98,93,88,84,80,77,75,74,74,73,73,73,74,76,78,81,85,90,95,101,108,116,124,136,149,165,162,145,133,121,113,106,101,95,90,86,82,79,77,76,75,75,75,75,76,78,80,83,87,92,98,104,110,118,127,139,152,167,165,149,136,124,116,108,103,97,93,88,84,81,79,78,77,77,77,77,78,80,82,86,89,95,100,106,112,120,130,143,155,170,169,153,140,128,118,111,105,100,95,91,87,84,82,80,80,79,79,79,80,82,85,88,92,97,102,108,115,123,134,146,158,175,174,156,143,131,121,113,107,102,97,93,89,86,84,83,82,81,81,81,83,85,87,91,95,99,105,111,118,127,137,149,161,177,179,162,146,134,123,115,110,104,100,96,92,89,86,85,84,84,83,84,85,87,90,93,98,102,107,113,121,130,141,154,166,180};

// R G B
static uint16_t _calibration_awb_warming_ls_a[] = {256,256,265};

// R G B
static uint16_t _calibration_awb_warming_ls_d75[] = {268,256,275};

// R G B
static uint16_t _calibration_awb_warming_ls_d50[] = {262,256,270};

// CALIBRATION_NOISE_PROFILE
static uint8_t _calibration_noise_profile[]
 = {0,0,0,0,0,0,0,0,9,25,32,36,38,41,43,45,46,47,49,50,51,52,52,53,54,55,55,55,56,57,57,58,58,59,59,60,60,61,61,61,62,62,62,63,63,63,64,64,64,64,65,65,65,66,66,66,66,66,67,67,67,67,68,68,68,68,68,69,69,69,69,69,70,70,70,70,70,70,71,71,71,71,71,71,71,72,72,72,72,72,72,72,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,77,77};

// CALIBRATION_DEMOSAIC
static uint8_t _calibration_demosaic[]
 = {7,23,29,33,36,38,40,42,43,44,46,47,48,49,50,50,51,52,52,53,53,54,55,55,55,56,56,57,57,58,58,58,59,59,59,60,60,60,61,61,61,62,62,62,62,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66,67,67,67,67,67,67,68,68,68,68,68,68,69,69,69,69,69,69,69,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74};

// 8-bit normalised noise profile for WDR stitching
static uint8_t _calibration_wdr_np_lut[]
 = {13,27,35,42,47,53,57,61,65,69,73,76,80,83,86,89,91,94,97,100,102,105,107,109,112,114,116,118,120,122,125,127,129,131,133,134,136,138,140,142,144,145,147,149,151,152,154,156,157,159,160,162,164,165,167,168,170,171,173,174,176,177,178,180,181,183,184,185,187,188,190,191,192,194,195,196,197,199,200,201,203,204,205,206,208,209,210,211,212,214,215,216,217,218,219,221,222,223,224,225,226,227,229,230,231,232,233,234,235,236,237,238,239,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255};

// CALIBRATION_GAMMA
static uint16_t _calibration_gamma[]
 = {0,347,539,679,794,894,982,1062,1136,1204,1268,1329,1386,1441,1493,1543,1591,1638,1683,1726,1768,1809,1849,1888,1926,1963,1999,2034,2068,2102,2135,2168,2200,2231,2262,2292,2322,2351,2380,2408,2436,2463,2491,2517,2544,2570,2596,2621,2646,2671,2695,2719,2743,2767,2790,2814,2836,2859,2882,2904,2926,2948,2969,2990,3012,3033,3053,3074,3094,3115,3135,3155,3174,3194,3213,3233,3252,3271,3290,3308,3327,3345,3364,3382,3400,3418,3436,3453,3471,3488,3506,3523,3540,3557,3574,3591,3607,3624,3640,3657,3673,3689,3705,3721,3737,3753,3769,3785,3800,3816,3831,3846,3862,3877,3892,3907,3922,3937,3951,3966,3981,3995,4010,4024,4039,4053,4067,4081,4095};

// CALIBRATION_IRIDIX_ASYMMETRY
static uint32_t _calibration_iridix_asymmetry[]
 = {0,62836,120267,172961,221481,266305,307839,346432,382386,415964,447392,476871,504577,530666,555274,578524,600526,621378,641167,659973,677867,694914,711172,726696,741534,755730,769325,782356,794859,806864,818400,829495,840173,850457,860369,869929,879155,888064,896672,904994,913045,920837,928383,935693,942780,949653,956321,962794,969080,975187,981123,986894,992508,997970,1003288,1008466,1013509,1018424,1023215,1027887,1032443,1036889,1041228,1045464,1048575};

static uint32_t _calibration_ca_filter_mem[]
 = {32768,229629,491259,4278943225,4279204855,4262689525,4246239220,4229788915,4213338610,4196888050,4197214450,4180763890,4164313330,4147928050,4131477235,4115091955,4098641140,4082190325,4082516470,4066065655,4066391800,4066652665,4066913530,4067239930,4067500795,4084473340,4101445885,4118418430,4152037375,4185721855,4219340544,4253025024};

// calibration_awb_scene_presets in the following order AWB_DAY_LIGHT AWB_CLOUDY AWB_INCANDESCENT AWB_FLOURESCENT AWB_TWILIGHT AWB_SHADE AWB_WARM_FLOURESCENT
static uint16_t _calibration_awb_scene_presets[7][2] = {
  { 256, 256 },
  { 324, 226 },
  { 172, 345 },
  { 222, 277 },
  { 222, 277 },
  { 364, 210 },
  { 183, 324 }
};

// CALIBRATION_CA_CORRECTION: MIN_CORRECTION, MESH_WIDTH, MESH_HEIGHT
static uint16_t _calibration_ca_correction[] = {1,64,64};

static uint16_t _calibration_ca_correction_mem[][10] = {
  { 58, 65525, 46, 65531, 65444, 65510, 65521, 79, 14, 65445 },
  { 65532, 27, 6, 65518, 65530, 65499, 28, 13, 14, 65493 },
  { 65452, 65529, 65486, 1, 140, 50, 25, 65452, 65512, 63 },
  { 65534, 65499, 1, 24, 17, 35, 65493, 65520, 6, 18 }};

static uint32_t _calibration_lut3d_mem[] = {0};

static uint32_t _calibration_decompander0_mem[] = {0, 32768, 65536, 98304, 131072, 163840, 196608, 229376, 262144, 294912, 327680, 360448, 393216, 425984, 458752, 491520, 524288, 557055, 589823, 622591, 655359, 688127, 720895, 753663, 786431, 819199, 851967, 884735, 917503, 950271, 983039, 1015807, 1048575};

static uint32_t _calibration_decompander1_mem[] = {0, 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440, 65536, 69632, 73728, 77824, 81920, 86016, 90112, 94208, 98304, 102400, 106496, 110592, 114688, 118784, 122880, 126976, 131072, 135168, 139264, 143360, 147456, 151552, 155648, 159744, 163840, 167936, 172032, 176128, 180224, 184320, 188416, 192512, 196608, 200704, 204800, 208896, 212992, 217088, 221184, 225280, 229376, 233472, 237568, 241664, 245760, 249856, 253952, 258048, 262144, 266240, 270336, 274432, 278528, 282624, 286720, 290816, 294912, 299008, 303104, 307200, 311296, 315392, 319488, 323584, 327680, 331776, 335872, 339968, 344064, 348160, 352256, 356352, 360448, 364544, 368640, 372736, 376832, 380928, 385024, 389120, 393216, 397312, 401408, 405504, 409600, 413696, 417792, 421888, 425984, 430080, 434176, 438272, 442368, 446464, 450560, 454656, 458752, 462848, 466944, 471040, 475136, 479232, 483328, 487424, 491520, 495616, 499712, 503808, 507904, 512000, 516096, 520192, 524288, 528383, 532479, 536575, 540671, 544767, 548863, 552959, 557055, 561151, 565247, 569343, 573439, 577535, 581631, 585727, 589823, 593919, 598015, 602111, 606207, 610303, 614399, 618495, 622591, 626687, 630783, 634879, 638975, 643071, 647167, 651263, 655359, 659455, 663551, 667647, 671743, 675839, 679935, 684031, 688127, 692223, 696319, 700415, 704511, 708607, 712703, 716799, 720895, 724991, 729087, 733183, 737279, 741375, 745471, 749567, 753663, 757759, 761855, 765951, 770047, 774143, 778239, 782335, 786431, 790527, 794623, 798719, 802815, 806911, 811007, 815103, 819199, 823295, 827391, 831487, 835583, 839679, 843775, 847871, 851967, 856063, 860159, 864255, 868351, 872447, 876543, 880639, 884735, 888831, 892927, 897023, 901119, 905215, 909311, 913407, 917503, 921599, 925695, 929791, 933887, 937983, 942079, 946175, 950271, 954367, 958463, 962559, 966655, 970751, 974847, 978943, 983039, 987135, 991231, 995327, 999423, 1003519, 1007615, 1011711, 1015807, 1019903, 1023999, 1028095, 1032191, 1036287, 1040383, 1044479, 1048575};

// CALIBRATION_SHADING_RADIAL_R
static uint16_t _calibration_shading_radial_r[]
 = {4096,4131,4167,4203,4240,4279,4318,4357,4398,4439,4482,4525,4569,4614,4659,4706,4753,4801,4850,4900,4950,5001,5054,5106,5160,5214,5269,5325,5381,5438,5495,5554,5612,5671,5731,5791,5852,5913,5974,6035,6097,6160,6222,6285,6348,6411,6474,6537,6601,6664,6728,6791,6855,6919,6982,7046,7110,7174,7238,7301,7365,7429,7493,7557,7622,7686,7751,7815,7880,7945,8011,8077,8143,8210,8277,8344,8412,8481,8550,8620,8691,8762,8834,8907,8981,9056,9132,9208,9286,9365,9445,9526,9609,9692,9777,9863,9950,10038,10127,10217,10308,10400,10494,10587,10682,10777,10872,10968,11063,11159,11254,11348,11442,11534,11624,11713,11799,11883,11964,12042,12116,12186,12252,12313,12368,12419,12463,12502,12534};

// CALIBRATION_SHADING_RADIAL_G
static uint16_t _calibration_shading_radial_g[]
 = {4096,4127,4159,4192,4226,4260,4294,4330,4366,4403,4441,4479,4518,4558,4598,4639,4681,4723,4767,4810,4855,4900,4946,4992,5039,5087,5135,5184,5234,5284,5334,5385,5437,5489,5541,5594,5647,5701,5755,5810,5864,5920,5975,6031,6087,6143,6200,6256,6313,6370,6428,6485,6543,6601,6658,6717,6775,6833,6892,6950,7009,7068,7127,7186,7246,7305,7365,7425,7485,7546,7607,7668,7729,7791,7854,7916,7979,8043,8107,8171,8237,8302,8369,8436,8504,8572,8642,8712,8783,8855,8928,9002,9077,9152,9229,9307,9386,9466,9548,9630,9714,9798,9884,9971,10058,10147,10237,10328,10420,10512,10605,10699,10793,10887,10982,11076,11171,11265,11358,11450,11541,11631,11719,11804,11887,11967,12043,12116,12184};

// CALIBRATION_SHADING_RADIAL_B
static uint16_t _calibration_shading_radial_b[]
 = {4096,4126,4157,4189,4222,4255,4288,4323,4358,4394,4430,4467,4505,4544,4583,4623,4664,4705,4747,4789,4833,4877,4921,4966,5012,5058,5105,5153,5201,5250,5299,5348,5399,5449,5500,5552,5604,5656,5709,5762,5816,5870,5924,5978,6033,6088,6143,6199,6254,6310,6366,6423,6479,6536,6593,6650,6707,6764,6821,6879,6937,6995,7053,7111,7170,7228,7287,7346,7406,7465,7525,7585,7646,7707,7768,7830,7892,7955,8018,8082,8146,8211,8277,8343,8410,8477,8546,8615,8685,8756,8828,8901,8975,9049,9125,9202,9280,9359,9439,9520,9602,9685,9770,9855,9941,10029,10117,10207,10297,10388,10479,10571,10664,10757,10850,10943,11036,11129,11221,11312,11402,11490,11577,11662,11744,11823,11899,11972,12040};

static LookupTable calibration_shading_radial_r = { .ptr = _calibration_shading_radial_r, .rows = 1, .cols = sizeof(_calibration_shading_radial_r) / sizeof(_calibration_shading_radial_r[0]), .width = sizeof(_calibration_shading_radial_r[0] ) };
static LookupTable calibration_shading_radial_g = { .ptr = _calibration_shading_radial_g, .rows = 1, .cols = sizeof(_calibration_shading_radial_g) / sizeof(_calibration_shading_radial_g[0]), .width = sizeof(_calibration_shading_radial_g[0] ) };
static LookupTable calibration_shading_radial_b = { .ptr = _calibration_shading_radial_b, .rows = 1, .cols = sizeof(_calibration_shading_radial_b) / sizeof(_calibration_shading_radial_b[0]), .width = sizeof(_calibration_shading_radial_b[0] ) };
static LookupTable calibration_decompander0_mem = {.ptr = _calibration_decompander0_mem, .rows = 1, .cols = sizeof( _calibration_decompander0_mem ) / sizeof( _calibration_decompander0_mem[0] ), .width = sizeof( _calibration_decompander0_mem[0] )};
static LookupTable calibration_decompander1_mem = {.ptr = _calibration_decompander1_mem, .rows = 1, .cols = sizeof( _calibration_decompander1_mem ) / sizeof( _calibration_decompander1_mem[0] ), .width = sizeof( _calibration_decompander1_mem[0] )};

static LookupTable calibration_awb_scene_presets = {.ptr = _calibration_awb_scene_presets, .cols = 2, .rows = sizeof( _calibration_awb_scene_presets ) / sizeof( _calibration_awb_scene_presets[0] ), .width = sizeof( _calibration_awb_scene_presets[0][0] )};
static LookupTable calibration_light_src = {.ptr = _calibration_light_src, .cols = 2, .rows = sizeof( _calibration_light_src ) / sizeof( _calibration_light_src[0] ), .width = sizeof( _calibration_light_src[0][0] )};
static LookupTable calibration_rg_pos = {.ptr = _calibration_rg_pos, .rows = 1, .cols = sizeof( _calibration_rg_pos ) / sizeof( _calibration_rg_pos[0] ), .width = sizeof( _calibration_rg_pos[0] )};
static LookupTable calibration_bg_pos = {.ptr = _calibration_bg_pos, .rows = 1, .cols = sizeof( _calibration_bg_pos ) / sizeof( _calibration_bg_pos[0] ), .width = sizeof( _calibration_bg_pos[0] )};
static LookupTable calibration_mesh_rgbg_weight = {.ptr = _calibration_mesh_rgbg_weight, .cols = 15, .rows = sizeof( _calibration_mesh_rgbg_weight ) / sizeof( _calibration_mesh_rgbg_weight[0] ), .width = sizeof( _calibration_mesh_rgbg_weight[0][0] )};
static LookupTable calibration_mesh_ls_weight = {.ptr = _calibration_mesh_ls_weight, .cols = 15, .rows = sizeof( _calibration_mesh_ls_weight ) / sizeof( _calibration_mesh_ls_weight[0] ), .width = sizeof( _calibration_mesh_ls_weight[0][0] )};
static LookupTable calibration_mesh_color_temperature = {.ptr = _calibration_mesh_color_temperature, .cols = 15, .rows = sizeof( _calibration_mesh_color_temperature ) / sizeof( _calibration_mesh_color_temperature[0] ), .width = sizeof( _calibration_mesh_color_temperature[0][0] )};
static LookupTable calibration_wb_strength = {.ptr = _calibration_wb_strength, .rows = 1, .cols = sizeof( _calibration_wb_strength ) / sizeof( _calibration_wb_strength[0] ), .width = sizeof( _calibration_wb_strength[0] )};
static LookupTable calibration_sky_lux_th = {.ptr = _calibration_sky_lux_th, .rows = 1, .cols = sizeof( _calibration_sky_lux_th ) / sizeof( _calibration_sky_lux_th[0] ), .width = sizeof( _calibration_sky_lux_th[0] )};
static LookupTable calibration_ct_rg_pos_calc = {.ptr = _calibration_ct_rg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_rg_pos_calc ) / sizeof( _calibration_ct_rg_pos_calc[0] ), .width = sizeof( _calibration_ct_rg_pos_calc[0] )};
static LookupTable calibration_ct_bg_pos_calc = {.ptr = _calibration_ct_bg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_bg_pos_calc ) / sizeof( _calibration_ct_bg_pos_calc[0] ), .width = sizeof( _calibration_ct_bg_pos_calc[0] )};
static LookupTable calibration_color_temp = {.ptr = _calibration_color_temp, .rows = 1, .cols = sizeof( _calibration_color_temp ) / sizeof( _calibration_color_temp[0] ), .width = sizeof( _calibration_color_temp[0] )};
static LookupTable calibration_ct65pos = {.ptr = _calibration_ct65pos, .rows = 1, .cols = sizeof( _calibration_ct65pos ) / sizeof( _calibration_ct65pos[0] ), .width = sizeof( _calibration_ct65pos[0] )};
static LookupTable calibration_ct40pos = {.ptr = _calibration_ct40pos, .rows = 1, .cols = sizeof( _calibration_ct40pos ) / sizeof( _calibration_ct40pos[0] ), .width = sizeof( _calibration_ct40pos[0] )};
static LookupTable calibration_ct30pos = {.ptr = _calibration_ct30pos, .rows = 1, .cols = sizeof( _calibration_ct30pos ) / sizeof( _calibration_ct30pos[0] ), .width = sizeof( _calibration_ct30pos[0] )};
static LookupTable calibration_evtolux_ev_lut = {.ptr = _calibration_evtolux_ev_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_ev_lut ) / sizeof( _calibration_evtolux_ev_lut[0] ), .width = sizeof( _calibration_evtolux_ev_lut[0] )};
static LookupTable calibration_evtolux_lux_lut = {.ptr = _calibration_evtolux_lux_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_lux_lut ) / sizeof( _calibration_evtolux_lux_lut[0] ), .width = sizeof( _calibration_evtolux_lux_lut[0] )};
static LookupTable calibration_black_level_r = {.ptr = _calibration_black_level_r, .cols = 2, .rows = sizeof( _calibration_black_level_r ) / sizeof( _calibration_black_level_r[0] ), .width = sizeof( _calibration_black_level_r[0][0] )};
static LookupTable calibration_black_level_gr = {.ptr = _calibration_black_level_gr, .cols = 2, .rows = sizeof( _calibration_black_level_gr ) / sizeof( _calibration_black_level_gr[0] ), .width = sizeof( _calibration_black_level_gr[0][0] )};
static LookupTable calibration_black_level_gb = {.ptr = _calibration_black_level_gb, .cols = 2, .rows = sizeof( _calibration_black_level_gb ) / sizeof( _calibration_black_level_gb[0] ), .width = sizeof( _calibration_black_level_gb[0][0] )};
static LookupTable calibration_black_level_b = {.ptr = _calibration_black_level_b, .cols = 2, .rows = sizeof( _calibration_black_level_b ) / sizeof( _calibration_black_level_b[0] ), .width = sizeof( _calibration_black_level_b[0][0] )};
static LookupTable calibration_static_wb = {.ptr = _calibration_static_wb, .rows = 1, .cols = sizeof( _calibration_static_wb ) / sizeof( _calibration_static_wb[0] ), .width = sizeof( _calibration_static_wb[0] )};
static LookupTable calibration_mt_absolute_ls_a_ccm = {.ptr = _calibration_mt_absolute_ls_a_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_a_ccm ) / sizeof( _calibration_mt_absolute_ls_a_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_a_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d40_ccm = {.ptr = _calibration_mt_absolute_ls_d40_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d40_ccm ) / sizeof( _calibration_mt_absolute_ls_d40_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d40_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d50_ccm = {.ptr = _calibration_mt_absolute_ls_d50_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d50_ccm ) / sizeof( _calibration_mt_absolute_ls_d50_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d50_ccm[0] )};
static LookupTable calibration_shading_ls_a_r = {.ptr = _calibration_shading_ls_a_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_r ) / sizeof( _calibration_shading_ls_a_r[0] ), .width = sizeof( _calibration_shading_ls_a_r[0] )};
static LookupTable calibration_shading_ls_a_g = {.ptr = _calibration_shading_ls_a_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_g ) / sizeof( _calibration_shading_ls_a_g[0] ), .width = sizeof( _calibration_shading_ls_a_g[0] )};
static LookupTable calibration_shading_ls_a_b = {.ptr = _calibration_shading_ls_a_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_b ) / sizeof( _calibration_shading_ls_a_b[0] ), .width = sizeof( _calibration_shading_ls_a_b[0] )};
static LookupTable calibration_shading_ls_tl84_r = {.ptr = _calibration_shading_ls_tl84_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_r ) / sizeof( _calibration_shading_ls_tl84_r[0] ), .width = sizeof( _calibration_shading_ls_tl84_r[0] )};
static LookupTable calibration_shading_ls_tl84_g = {.ptr = _calibration_shading_ls_tl84_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_g ) / sizeof( _calibration_shading_ls_tl84_g[0] ), .width = sizeof( _calibration_shading_ls_tl84_g[0] )};
static LookupTable calibration_shading_ls_tl84_b = {.ptr = _calibration_shading_ls_tl84_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_b ) / sizeof( _calibration_shading_ls_tl84_b[0] ), .width = sizeof( _calibration_shading_ls_tl84_b[0] )};
static LookupTable calibration_shading_ls_d65_r = {.ptr = _calibration_shading_ls_d65_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_r ) / sizeof( _calibration_shading_ls_d65_r[0] ), .width = sizeof( _calibration_shading_ls_d65_r[0] )};
static LookupTable calibration_shading_ls_d65_g = {.ptr = _calibration_shading_ls_d65_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_g ) / sizeof( _calibration_shading_ls_d65_g[0] ), .width = sizeof( _calibration_shading_ls_d65_g[0] )};
static LookupTable calibration_shading_ls_d65_b = {.ptr = _calibration_shading_ls_d65_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_b ) / sizeof( _calibration_shading_ls_d65_b[0] ), .width = sizeof( _calibration_shading_ls_d65_b[0] )};
static LookupTable calibration_awb_warming_ls_a = {.ptr = _calibration_awb_warming_ls_a, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_a ) / sizeof( _calibration_awb_warming_ls_a[0] ), .width = sizeof( _calibration_awb_warming_ls_a[0] )};
static LookupTable calibration_awb_warming_ls_d50 = {.ptr = _calibration_awb_warming_ls_d50, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d50 ) / sizeof( _calibration_awb_warming_ls_d50[0] ), .width = sizeof( _calibration_awb_warming_ls_d50[0] )};
static LookupTable calibration_awb_warming_ls_d75 = {.ptr = _calibration_awb_warming_ls_d75, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d75 ) / sizeof( _calibration_awb_warming_ls_d75[0] ), .width = sizeof( _calibration_awb_warming_ls_d75[0] )};
static LookupTable calibration_noise_profile = {.ptr = _calibration_noise_profile, .rows = 1, .cols = sizeof( _calibration_noise_profile ) / sizeof( _calibration_noise_profile[0] ), .width = sizeof( _calibration_noise_profile[0] )};
static LookupTable calibration_demosaic = {.ptr = _calibration_demosaic, .rows = 1, .cols = sizeof( _calibration_demosaic ) / sizeof( _calibration_demosaic[0] ), .width = sizeof( _calibration_demosaic[0] )};
static LookupTable calibration_wdr_np_lut = {.ptr = _calibration_wdr_np_lut, .rows = 1, .cols = sizeof( _calibration_wdr_np_lut ) / sizeof( _calibration_wdr_np_lut[0] ), .width = sizeof( _calibration_wdr_np_lut[0] )};
static LookupTable calibration_gamma = {.ptr = _calibration_gamma, .rows = 1, .cols = sizeof( _calibration_gamma ) / sizeof( _calibration_gamma[0] ), .width = sizeof( _calibration_gamma[0] )};
static LookupTable calibration_iridix_asymmetry = {.ptr = _calibration_iridix_asymmetry, .rows = 1, .cols = sizeof( _calibration_iridix_asymmetry ) / sizeof( _calibration_iridix_asymmetry[0] ), .width = sizeof( _calibration_iridix_asymmetry[0] )};
static LookupTable calibration_ca_filter_mem = {.ptr = _calibration_ca_filter_mem, .rows = 1, .cols = sizeof( _calibration_ca_filter_mem ) / sizeof( _calibration_ca_filter_mem[0] ), .width = sizeof( _calibration_ca_filter_mem[0] )};
static LookupTable calibration_ca_correction = {.ptr = _calibration_ca_correction, .rows = 1, .cols = sizeof( _calibration_ca_correction ) / sizeof( _calibration_ca_correction[0] ), .width = sizeof( _calibration_ca_correction[0] )};
static LookupTable calibration_ca_correction_mem = {.ptr = _calibration_ca_correction_mem, .cols = 10, .rows = sizeof( _calibration_ca_correction_mem ) / sizeof( _calibration_ca_correction_mem[0] ), .width = sizeof( _calibration_ca_correction_mem[0][0] )};
static LookupTable calibration_lut3d_mem = {.ptr = _calibration_lut3d_mem, .rows = 1, .cols = sizeof( _calibration_lut3d_mem ) / sizeof( _calibration_lut3d_mem[0] ), .width = sizeof( _calibration_lut3d_mem[0] )};

uint32_t get_calibrations_static_fs_lin_sc8238cs_tv( ACameraCalibrations *c )
{
    uint32_t result = 0;
    if ( c != 0 ) {
        c->calibrations[CALIBRATION_SHADING_RADIAL_R] = &calibration_shading_radial_r;
        c->calibrations[CALIBRATION_SHADING_RADIAL_G] = &calibration_shading_radial_g;
        c->calibrations[CALIBRATION_SHADING_RADIAL_B] = &calibration_shading_radial_b;
        c->calibrations[CALIBRATION_DECOMPANDER0_MEM] = &calibration_decompander0_mem;
        c->calibrations[CALIBRATION_DECOMPANDER1_MEM] = &calibration_decompander1_mem;
        c->calibrations[CALIBRATION_LIGHT_SRC] = &calibration_light_src;
        c->calibrations[CALIBRATION_RG_POS] = &calibration_rg_pos;
        c->calibrations[CALIBRATION_BG_POS] = &calibration_bg_pos;
        c->calibrations[CALIBRATION_MESH_RGBG_WEIGHT] = &calibration_mesh_rgbg_weight;
        c->calibrations[CALIBRATION_MESH_LS_WEIGHT] = &calibration_mesh_ls_weight;
        c->calibrations[CALIBRATION_MESH_COLOR_TEMPERATURE] = &calibration_mesh_color_temperature;
        c->calibrations[CALIBRATION_WB_STRENGTH] = &calibration_wb_strength;
        c->calibrations[CALIBRATION_SKY_LUX_TH] = &calibration_sky_lux_th;
        c->calibrations[CALIBRATION_CT_RG_POS_CALC] = &calibration_ct_rg_pos_calc;
        c->calibrations[CALIBRATION_CT_BG_POS_CALC] = &calibration_ct_bg_pos_calc;
        c->calibrations[CALIBRATION_COLOR_TEMP] = &calibration_color_temp;
        c->calibrations[CALIBRATION_CT65POS] = &calibration_ct65pos;
        c->calibrations[CALIBRATION_CT40POS] = &calibration_ct40pos;
        c->calibrations[CALIBRATION_CT30POS] = &calibration_ct30pos;
        c->calibrations[CALIBRATION_EVTOLUX_EV_LUT] = &calibration_evtolux_ev_lut;
        c->calibrations[CALIBRATION_EVTOLUX_LUX_LUT] = &calibration_evtolux_lux_lut;
        c->calibrations[CALIBRATION_BLACK_LEVEL_R] = &calibration_black_level_r;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GR] = &calibration_black_level_gr;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GB] = &calibration_black_level_gb;
        c->calibrations[CALIBRATION_BLACK_LEVEL_B] = &calibration_black_level_b;
        c->calibrations[CALIBRATION_STATIC_WB] = &calibration_static_wb;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_A_CCM] = &calibration_mt_absolute_ls_a_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D40_CCM] = &calibration_mt_absolute_ls_d40_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D50_CCM] = &calibration_mt_absolute_ls_d50_ccm;
        c->calibrations[CALIBRATION_SHADING_LS_A_R] = &calibration_shading_ls_a_r;
        c->calibrations[CALIBRATION_SHADING_LS_A_G] = &calibration_shading_ls_a_g;
        c->calibrations[CALIBRATION_SHADING_LS_A_B] = &calibration_shading_ls_a_b;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_R] = &calibration_shading_ls_tl84_r;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_G] = &calibration_shading_ls_tl84_g;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_B] = &calibration_shading_ls_tl84_b;
        c->calibrations[CALIBRATION_SHADING_LS_D65_R] = &calibration_shading_ls_d65_r;
        c->calibrations[CALIBRATION_SHADING_LS_D65_G] = &calibration_shading_ls_d65_g;
        c->calibrations[CALIBRATION_SHADING_LS_D65_B] = &calibration_shading_ls_d65_b;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_A] = &calibration_awb_warming_ls_a;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D50] = &calibration_awb_warming_ls_d50;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D75] = &calibration_awb_warming_ls_d75;
        c->calibrations[CALIBRATION_NOISE_PROFILE] = &calibration_noise_profile;
        c->calibrations[CALIBRATION_DEMOSAIC] = &calibration_demosaic;
        c->calibrations[CALIBRATION_WDR_NP_LUT] = &calibration_wdr_np_lut;
        c->calibrations[CALIBRATION_GAMMA] = &calibration_gamma;
        c->calibrations[CALIBRATION_IRIDIX_ASYMMETRY] = &calibration_iridix_asymmetry;
        c->calibrations[CALIBRATION_AWB_SCENE_PRESETS] = &calibration_awb_scene_presets;
        c->calibrations[CALIBRATION_CA_FILTER_MEM] = &calibration_ca_filter_mem;
        c->calibrations[CALIBRATION_CA_CORRECTION] = &calibration_ca_correction;
        c->calibrations[CALIBRATION_CA_CORRECTION_MEM] = &calibration_ca_correction_mem;
        c->calibrations[CALIBRATION_LUT3D_MEM] = &calibration_lut3d_mem;
    } else {
        result = -1;
    }
    return result;
}
